// pages/enroll/enroll.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    uploadProFrontShow: '',
    uploadList: [{
      id: 0,
      img: '../../images/rank_product_img_demo.jpg'
    },{
      id: 1,
      img: '../../images/product_img_demo.jpg'
    },{
      id: 2,
      img: '../../images/product_list_img_demo.jpg'
    }],
    
    isChecked: false,

    companyNameError: false,
    companyCodeError: false,
    productNameError: false,
    proFrontError: false,
    proListError: false,
    proIntroError: false,
    contactNameError: false,
    contactPhoneError: false,

    popShow: false,
    popNotice: false,
    popTips: false,
    companyName: 'XXXXXXX'
  },

  uploadedDeleteTap(e) {
    let id = e.currentTarget.id, list = this.data.uploadList, index=0;
    for (let i=0;i<list.length;i++) {
      if (id == list[i].id) {
        index = list.indexOf(list[i]);
        if (index > -1) { 
          list.splice(index, 1); 
        }
      }
    }
    this.setData({
      uploadList: list
    })
  },

  popConfirmTap(e) {
    this.setData({
      popNotice: false,
      popTips: true
    })
  },

  popCancelTap(e) {
    this.setData({
      popShow: false,
      popNotice: false
    })
  },

  submitTap(e) {
    this.setData({
      popShow: true,
      popNotice: true
    })
  },

  uploadProListTap(e) {
    let that = this;
    wx.chooseMedia({
      count: 5,
      mediaType: ['image'],
      success(res) {
        console.log(res.tempFiles[0]);
      }
    })
  },

  uploadProFrontTap(e) {
    let that = this;
    wx.chooseMedia({
      count: 1,
      mediaType: ['image'],
      success(res) {
        console.log(res.tempFiles[0]);
      }
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})